//
//  Images.swift
//  CreateChina
//
//  Created by 贾培军 on 2020/4/23.
//  Copyright © 2020 贾培军. All rights reserved.
//

import UIKit

public extension UIImage{
    class func image(_ color:UIColor, _ size:CGSize = .init(width: 1, height: 1))->UIImage{
        let rect:CGRect = .init(x: 0, y: 0, width: size.width, height: size.height)
        UIGraphicsBeginImageContext(rect.size)
        let context = UIGraphicsGetCurrentContext()
        context?.setFillColor(color.cgColor)
        context?.fill(rect)
        let im = UIGraphicsGetImageFromCurrentImageContext()
        UIGraphicsEndImageContext()
        return im ?? UIImage()
    }
}
